#pragma once

#include <QQuaternion>

#include <libz800.h>

#include "ui_MainWindow.h"

class QTimer;
class DlgRawData;
class DlgGyroCalib;
class DlgDisplay;
class DlgProperties;

class MainWindow : public QMainWindow
				 , protected Ui_MainWindow
{
	Q_OBJECT

public:
	MainWindow(z800_device *dev, QWidget *parent = NULL);

public slots:
	void setStereoEnabled(bool enabled);

signals:
	void rawDataChanged(const QVector3D &gyr, const QVector3D &acc, const QVector3D &mag);
	void gyroSpeedChanged(const QVector3D &gyrSpeed);
	void stabilizationChanged(const QQuaternion &q);
	void quatChanged(const QQuaternion &q);
	void eulerChanged(const QVector3D &euler);

protected slots:
	void update();
	void on_actionRaw_Data_triggered();
	void on_actionGyro_Calibration_triggered();
	void on_actionDisplay_triggered();
	void on_actionEEPROM_triggered();
	void on_actionCalibrateAccMag_triggered();
	void on_displayComboBox_currentIndexChanged(int index);

protected:
	void readSettings();
	void writeSettings();
	void closeEvent(QCloseEvent *event);
	void keyPressEvent(QKeyEvent *e);

	z800_device *_dev;
	QTimer *_timer;
	DlgRawData *_dlgRawData;
	DlgGyroCalib *_dlgGyroCalib;
	DlgDisplay *_dlgDisplay;
	DlgProperties *_dlgProperties;
	int _mode;
	bool _stereo;
};
